/**
 * Copyright (c) 2005-2016, cnfuelteam (fuelteam@163.com)"
 * 
 * Licensed under The MIT License (MIT)
 */
package com.fullhome8.cn.wanghongweb.biz.impl;

import com.fullhome8.cn.wanghongweb.biz.NewsBiz;
import com.fullhome8.cn.wanghongweb.dao.NewsDao;
import com.fullhome8.cn.wanghongweb.model.News;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述： （news） 接口实现
 * 
 * 作者： yuanxuefeng
 * 时间： 2017-04-25 17:14:12
 */
@Service
public class NewsBizImpl implements NewsBiz {

	@Autowired
	private NewsDao newsDao;

	public PageInfo<News> findPage(int pageNum, int pageSize, Map<String, Object> params) {
		PageHelper.startPage(pageNum, pageSize);
		List<News> list = newsDao.findByParams(params);
		PageInfo<News> page = new PageInfo<News>(list);
		return page;
	}



	public News get(Long id) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		List<News> list = newsDao.findByParams(params);
		if(list == null || list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}


}

